package Demo09;

import java.util.HashMap;
import java.util.Map;
import java.util.Random;

public class Maptest {
    public static void main(String[] args) {
        String[] chosen = {"A","B","C","D"};
        StringBuilder sb = new StringBuilder();
        Random r  = new Random();
        for (int i = 0; i < 80; i++) {
            sb.append(chosen[r.nextInt(chosen.length)]);
        }
        System.out.println(sb);

        Map<Character,Integer> maps = new HashMap<>();

        for (int i = 0; i < sb.length(); i++) {
            char ch = sb.charAt(i);
            if(maps.containsKey(ch)){
                maps.put(ch, maps.get(ch) + 1);
            }else {
                maps.put(ch,1);
            }
        }

        System.out.println(maps);
    }
}
